using System;
using Castle.MonoRail.Framework;
using Castle.MonoRail.ActiveRecordSupport;
using DecisionesInteligentes.iEvalua.Models;
using DecisionesInteligentes.iEvalua.Web.Services;
using DecisionesInteligentes.iEvalua.Web.Filters;
using NHibernate.Expression;

namespace DecisionesInteligentes.iEvalua.Web.Controllers
{
	[Layout("roles")]
	[Filter(ExecuteEnum.BeforeAction, typeof(AuthenticationFilter), ExecutionOrder=1)]
	public class RolesController : BaseController<Role>
	{
		public override void Index()
		{
			List(null, new ICriterion[]
				{
					new EqExpression("ApplicationId", Application.Id)
				}
			);
		}
		
		protected override void CreateNew(Role role)
		{
			role.Application = Application;
			base.CreateNew(role);
		}
	}
}